﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

using LeanEngine.Extensions;

namespace LeanEngine.Collections
{
    /// <summary>
    /// Represents a strongly typed list of objects which are paged. 
    /// </summary>
    /// <typeparam name="T">The type of elements in list.</typeparam>
    [Serializable]  
    public sealed class PagedList<T>
        where T : class
    {
        #region Constructor Members

        /// <summary>
        /// Initialize a new instance of the Core.Collections.PagedList class
        /// </summary>
        public PagedList()
        {
            this.Items = new List<T>();
        }

        #endregion

        #region PropertyInfo Members

        /// <summary>
        /// Gets or sets the zero-based index of the page.
        /// </summary>
        public int PageIndex
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the size of the page.
        /// </summary>
        public int PageSize
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the total quantity of items.
        /// </summary>
        public long TotalItems
        {
            get;
            set;
        }

        /// <summary>
        /// Gets the number of pages of data available.
        /// </summary>
        public int PageCount
        {
            get { return (TotalItems / PageSize).ToInt32(); }
        }

        /// <summary>
        /// Gets or sets the System.Collections.Generic.List representing the items of the current page.
        /// </summary>
        public List<T> Items
        {
            get;
            set;
        }

        #endregion
    }
}
